﻿Public Class frmXemKho
    Private Sub frmXemKho_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        LayHangHoa()
        cbbLocTheoTenHangHoa.DataSource = TapHoaDAO.LayTenHangHoa()
        cbbLocTheoTenHangHoa.DisplayMember = "hh_TenHang"
        cbbLocTheoTenHangHoa.ValueMember = "hh_ID"
    End Sub

    Private Sub btnThem_Click(sender As System.Object, e As System.EventArgs) Handles btnThem.Click
        Dim frm As frmNhapHang = New frmNhapHang()
        frm.Show()
    End Sub

    Private Sub btnCapNhat_Click(sender As System.Object, e As System.EventArgs) Handles btnCapNhat.Click
        Dim frm As frmCapNhatKho = New frmCapNhatKho()
        frm.IDHangHoa = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_ID").Value)
        frm.TenHang = dgvXemKho.CurrentRow.Cells("hh_TenHang").Value
        frm.Gia = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_Gia").Value)
        frm.SoLuong = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_SoLuong").Value)
        frm.DonVi = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_DonVi").Value)
        frm.NhaCungCap = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_NhaCungCap").Value)
        frm.XuatXu = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_XuatXu").Value)
        frm.LoaiHang = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_LoaiHang").Value)
        frm.ViTri = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_ViTri").Value)
        frm.LinkPic = dgvXemKho.CurrentRow.Cells("hh_HinhAnh").Value
        frm.Show()

    End Sub

    Private Sub btnXoa_Click(sender As System.Object, e As System.EventArgs) Handles btnXoa.Click
        Dim _hanghoa As New TapHoa()
        _hanghoa.m_intIDHangHoa = Integer.Parse(dgvXemKho.CurrentRow.Cells("hh_ID").Value)
        hh_HinhAnh = dgvXemKho.CurrentRow.Cells("hh_HinhAnh").Value
        TapHoaDAO.XoaHangHoa(_hanghoa)
        LayHangHoa()
    End Sub

    Public Sub LayHangHoa()
        Dim dt As DataTable = TapHoaDAO.LayHangHoafrmThemKho()
        dgvXemKho.DataSource = dt
    End Sub

    Private Sub btnThoat_Click(sender As System.Object, e As System.EventArgs) Handles btnThoat.Click
        me.Close()
    End Sub

    Private Sub btnXemTatCa_Click(sender As System.Object, e As System.EventArgs) Handles btnXemTatCa.Click
        LayHangHoa()
    End Sub

    Private Sub btnOK_Click(sender As System.Object, e As System.EventArgs) Handles btnLoc.Click
        Dim _TapHoa As New TapHoa()
        _TapHoa.m_intIDHangHoa = Integer.Parse(cbbLocTheoTenHangHoa.SelectedValue.ToString())
        dgvXemKho.DataSource = TapHoaDAO.LocTheoTenHangHoa(_TapHoa)
    End Sub
End Class